﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using util;
using dto;
using System.Data;
using System.Collections;
using MySql.Data;
using MySql.Data.MySqlClient;
namespace dao
{
    public class PermissionDAO
    {
        public DataTable getAllPermission()
        {
            DataTable dt = new DataTable();
            try
            {
                DataUtil.connect();
                String cmdText = "sp_GetAllPermission";
                dt = DataUtil.executeStore(cmdText, null);

            }
            catch (Exception ex)
            {
            }
            return dt;
        }
        public DataTable getPermissionRoleByPermissionID(String permissionID)
        {
            DataTable dt = new DataTable();
            try
            {
                DataUtil.connect();
                String cmdText = "sp_getPermissionRoleByPermissionID";
                MySqlParameter[] arrParam = new MySqlParameter[1];
                arrParam[0] = new MySqlParameter("_PermissionID", permissionID);
                dt = DataUtil.executeStore(cmdText, null);

            }
            catch (Exception ex)
            {
            }
            return dt;
        }
        public Boolean setPermissionUserByID(String id, String status)
        {
            Boolean result = false;
            try
            {
                DataUtil.connect();
                String cmdText = "sp_setPermissionUserByLoginIDAndPermissionRoleID";
                MySqlParameter[] arrParam = new MySqlParameter[2];
                arrParam[0] = new MySqlParameter("_ID", id);
                arrParam[1] = new MySqlParameter("_Status", status);
                result = DataUtil.executeNonQuery(cmdText, arrParam);
            }
            catch (Exception ex)
            {
            }
            return result;
        }
        public DataTable getAllPermissionType()
        {
            DataTable dt = new DataTable();
            try
            {
                DataUtil.connect();
                String cmdText = "sp_GetAllTypePermission";
                dt = DataUtil.executeStore(cmdText, null);
                
            }
            catch (Exception ex)
            {
            }
            return dt;
        }
    }
}
